package com.service.wmt.impl;

import com.dao.BuildListDAO;
import com.dao.HouseDao;
import com.dao.HouseDetailDAO;
import com.entity.House;
import com.entity.HouseDetail;
import com.entity.HouseList;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.service.wmt.BuildManagerService;
import com.util.gzp.AjaxResponse;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
@Service
@Transactional
public class BuildManagerServiceImpl implements BuildManagerService {

    @Resource
    private BuildListDAO buildListDAO;
    @Resource
    private HouseDetailDAO houseDetailDAO;
    @Resource
    private HouseDao houseDao;

    @Override
    public List<HouseList> findAllHouse() {
        return buildListDAO.findAll();
    }

    @Override
    public AjaxResponse findAll(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<HouseList> list = buildListDAO.findAll();
        PageInfo<HouseList> houseListPageInfo = new PageInfo<>(list);
        return AjaxResponse.success(houseListPageInfo);
    }

    @Override
    public HouseDetail findHouseDetailByHid(Integer hid) {
        return houseDetailDAO.findHouseDetailByHid(hid);
    }

    @Override
    public List<HouseList> findByName(String hname) {

        return buildListDAO.findByName(hname);
    }
}